package com.zx.zxpicture.application.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zx.zxpicture.infrstructure.common.BaseResponse;
import com.zx.zxpicture.interfaces.dto.space.SpaceAddRequest;
import com.zx.zxpicture.interfaces.dto.space.SpaceLevel;
import com.zx.zxpicture.interfaces.dto.space.SpaceQueryRequest;
import com.zx.zxpicture.domain.space.entity.Space;
import com.zx.zxpicture.domain.user.entity.User;
import com.zx.zxpicture.interfaces.vo.SpaceVO;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @author ZX
 * @description 针对表【space(空间)】的数据库操作Service
 * @createDate 2025-02-19 15:03:21
 */
public interface SpaceApplicationService extends IService<Space>{
    /**
     * 校验空间
     * @param space
     * @add 用来标识是添加空间还是修改空间
     */
    public void validSpace(Space space,Boolean add);

    /**
     * 创建空间
     * @param spaceAddRequest
     * @param loginUser
     * @return 空间id
     */
    public long addSpace(SpaceAddRequest spaceAddRequest,User loginUser);

    /**
     * 获取查询条件
     *
     * @param spaceQueryRequest
     * @return
     */
    QueryWrapper<Space> getQueryWrapper(SpaceQueryRequest spaceQueryRequest);

    /**
     * 封装返回空间对象
     * @param space
     * @param request
     * @return
     */
    public SpaceVO getSpaceVO(Space space, HttpServletRequest request);


    /**
     * 根据空间级别，自动填充限额
     * @param spacePage
     * @param request
     * @return
     */
    public Page<SpaceVO> getSpaceVOPage(Page<Space> spacePage, HttpServletRequest request);

    /**
     * 自动填充空间大小和额度
     * @param space
     */
    public void fillSpaceBySpaceLevel(Space space);

    /**
     * 校验空间权限
     * @param loginUser
     * @param space
     */
    void checkSpaceAuth(User loginUser, Space space);

    public BaseResponse<List<SpaceLevel>> listSpaceLevel();

    Space getById(Long spaceId);

    Collection<Space> listByIds(Set<Long> spaceIdSet);
}
